package com.service.controller;

import com.service.demo.SnmpClient;
import com.service.service.SnmpServiceImpl;
import org.snmp4j.mp.SnmpConstants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class Controller {

    int i = 0;

    @RequestMapping("/do")
    public String test() {
        System.out.println("hello_" + (i++));
        SnmpServiceImpl.doSnmp();
        return "success_" + i;
    }

    @GetMapping("/get")
    public String get(String param) {
        System.out.println(param);
        return param;
    }

    @GetMapping("/sendTrap")
    public String sendTrap() {
        try {
            SnmpClient client = new SnmpClient("udp:localhost/9001", "public", "public", "public", "public", "public", SnmpConstants.version2c);
            client.send("1.0.3");
            client.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "发送trap";
    }

    @GetMapping("/test")
    public String get() {
        System.out.println("hello");
        return "hello";
    }


}
